package com.zyp.test.test;

import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.OvershootInterpolator;

/**
 * @author zyp
 *         2017/12/25
 */

public class Main6Activity extends AppCompatActivity {

    private ObjectAnimator mObjectAnimator;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main6);
        PropertyValuesHolder pvh1 = PropertyValuesHolder.ofFloat("length",500);
        PropertyValuesHolder pvh2 = PropertyValuesHolder.ofFloat("paintWidth",20);
        ObjectAnimatorTest view = (ObjectAnimatorTest) findViewById(R.id.animator_view);
        //mObjectAnimator = ObjectAnimator.ofFloat(view,"length",0,500);
        mObjectAnimator = ObjectAnimator.ofPropertyValuesHolder(view,pvh1,pvh2);
        mObjectAnimator.setInterpolator(new OvershootInterpolator());
        mObjectAnimator.setDuration(3000);
        mObjectAnimator.setRepeatCount(ValueAnimator.INFINITE);
        mObjectAnimator.setRepeatMode(ValueAnimator.RESTART);
        
    }

    @Override
    protected void onResume() {
        super.onResume();
       
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        if(hasFocus){
            mObjectAnimator.start();
        }
    }
}
